STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} )
set(MODULE_NAME ${CURRENT_FOLDER})

set(FREEBSD_COMPAT_LINUX_PATH ../../${LITEOS_OPENSOURCE_PATHNAME}/freebsd/liteos/compat/linux)

# add global include, compile macro and options to public target #
set(MODULE_CXXINCLUDE_PUB)
set(MODULE_COPTS_PUB)
set(MODULE_ASOPTS_PUB)
set(MODULE_CXXOPTS_PUB)
set(MODULE_CMACRO_PUB)
set(MODULE_ASMACRO_PUB)
set(MODULE_CXXMACRO_PUB)


# add local include, compile macro and options to private target #
set(MODULE_INCLUDE_PRI ${LITEOSTOPDIR}/lib/libc/tzcode)

set(MODULE_COPTS_PRI ${LITEOS_NON_SECURE_LOCAL_OPTS})
set(MODULE_ASOPTS_PRI ${LITEOS_NON_SECURE_LOCAL_OPTS})
set(MODULE_CXXOPTS_PRI ${LITEOS_NON_SECURE_LOCAL_OPTS})
set(MODULE_CMACRO_PRI)
set(MODULE_ASMACRO_PRI)
set(MODULE_CXXMACRO_PRI)


# add srcs to private target #
set(LOCAL_SRCS_y src/adp.c src/time.c src/module.c)

list(APPEND LOCAL_SRCS_y ${LOCAL_SRCS_LIST_TEMP})

list(APPEND LOCAL_SRCS_${LOSCFG_COMPAT_LINUX_USED} src/atomic.c)

if (LOSCFG_COMPAT_LINUX_CHECKSUM)
if (LOSCFG_ARCH_ARM_AARCH64)
    list(APPEND MODULE_CMACRO_PUB _BYTE_ORDER=1234 _LITTLE_ENDIAN=1234)
    file(GLOB LOCAL_SRCS_LIST_TEMP "${FREEBSD_COMPAT_LINUX_PATH}/src/arm-arch/a53/*.c")
    list(APPEND LOCAL_SRCS_y ${LOCAL_SRCS_LIST_TEMP})
elseif (LOSCFG_ARCH_ARM_AARCH32 AND NOT LOSCFG_ARCH_ARM_CORTEX_M)
    file(GLOB LOCAL_SRCS_LIST_TEMP "${FREEBSD_COMPAT_LINUX_PATH}/src/arm-arch/common/*.S")
    list(APPEND LOCAL_SRCS_y ${LOCAL_SRCS_LIST_TEMP})

    file(GLOB LOCAL_SRCS_LIST_TEMP "${FREEBSD_COMPAT_LINUX_PATH}/src/arm-arch/common/*.c")
    list(APPEND LOCAL_SRCS_y ${LOCAL_SRCS_LIST_TEMP})
endif()
endif()

list(APPEND LOCAL_SRCS_${LOSCFG_COMPAT_LINUX_PENDLIST} src/common/pendlist.c)
list(APPEND LOCAL_SRCS_${LOSCFG_COMPAT_LINUX_TIMER} src/timer.c)
list(APPEND LOCAL_SRCS_${LOSCFG_COMPAT_LINUX_HRTIMER} src/hrtimer.c)
list(APPEND LOCAL_SRCS_${LOSCFG_COMPAT_LINUX_IRQ} src/interrupt.c)
list(APPEND LOCAL_SRCS_${LOSCFG_COMPAT_LINUX_SEMAPHORE} src/semaphore.c)
list(APPEND LOCAL_SRCS_${LOSCFG_COMPAT_LINUX_COMPLETION} src/completion.c)
list(APPEND LOCAL_SRCS_${LOSCFG_COMPAT_LINUX_WAITQUEUE} src/wait.c)
list(APPEND LOCAL_SRCS_${LOSCFG_COMPAT_LINUX_WORKQUEUE} src/workqueue.c)
list(APPEND LOCAL_SRCS_${LOSCFG_COMPAT_LINUX_DRIVER_BASE} src/driver.c)
list(APPEND LOCAL_SRCS_${LOSCFG_COMPAT_LINUX_WAKELOCK} src/wakelock.c)
list(APPEND LOCAL_SRCS_${LOSCFG_COMPAT_LINUX_RW_SEMAPHORE} src/rwsem.c)
list(APPEND LOCAL_SRCS_${LOSCFG_COMPAT_LINUX_CRC32} src/crc32.c)
list(APPEND LOCAL_SRCS_${LOSCFG_COMPAT_LINUX_RBTREE} src/rbtree.c)
list(APPEND LOCAL_SRCS_${LOSCFG_COMPAT_LINUX_MTD_LIST} src/mtd_list.c)

if (LOSCFG_COMPAT_LINUX_RBTREE)
    list(APPEND MODULE_COPTS_PRI -fno-strict-aliasing)
    list(APPEND MODULE_CXXOPTS_PRI -fno-strict-aliasing)
endif()

set(LOCAL_SRCS ${LOCAL_SRCS_y})
include(${MODULE})
